home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 08 - 1992 / 08.06 Oct 92 / Long Text Lists / BLInit.P < prev    next >
Encoding:
Text File  |  1992-03-26  |  5.5 KB  |  205 lines  |  [TEXT/MPS ]

  1. UNIT  BLInit;  {•••• Initialization routines ••••}
  2.  
  3. INTERFACE
  4.  
  5. USES  Memtypes,QuickDraw,OSIntf,ToolIntf,
  6.       PackIntf,FixMath,ObjIntf,BLObject;
  7.  
  8. PROCEDURE InitBigList;
  9. PROCEDURE SetUpMenus;
  10. PROCEDURE SetUpPseudoDialog;
  11.  
  12. IMPLEMENTATION
  13. {$S SegInit}
  14. {••••••••••••••••••••••••••••••••••••••••••••••••}
  15. PROCEDURE InitBigList;
  16.    PROCEDURE SetUpMultiFinder;   {Set “wneExists”}
  17.    CONST WNETrapNum = $60; {Nº of “WaitNextEvent”}
  18.          UnImplTrap = $9F;  {Unimplemented trap #}
  19.    VAR   world  :  SysEnvRec;
  20.          error  :  OSErr;
  21.    BEGIN
  22.       error:= SysEnvirons(1,world);
  23.       IF error = noErr THEN BEGIN
  24.          IF world.machineType<0 THEN ExitToShell;
  25.          wneExists:= (world.machineType >= 0) AND
  26.            (NGetTrapAddress(WNETrapNum,ToolTrap)<>
  27.             NGetTrapAddress(UnImplTrap,ToolTrap));
  28.       END
  29.       ELSE wneExists:= FALSE;
  30.    END;
  31. BEGIN
  32.    {Basic toolbox initializations}
  33.    MaxApplZone;
  34.    InitGraf(@thePort);
  35.    InitFonts;
  36.    InitWindows;
  37.    InitMenus;
  38.    TEInit;
  39.    InitDialogs(NIL);
  40.    {Event-management globals}
  41.    weAreDone:= FALSE;
  42.    inBckGrnd:= FALSE;
  43.    SetUpMultiFinder;
  44.    dublClick:= FALSE;
  45.    SetPt(lastClikPoint,0,0);
  46.    lastClikTime:= 0;
  47.    FlushEvents(everyEvent,0);
  48.    {Initialize the cursors}
  49.    XCursor:= GetCursor(crossCursor);
  50.    HLock(Handle(XCursor));
  51.    waitCursor:= GetCursor(watchCursor);
  52.    HLock(Handle(waitCursor));
  53.    SetCursor(waitCursor^^);
  54.    {Init. “styleVector” for top of Style menu}
  55.    styleVector[2]:= bold;
  56.    styleVector[3]:= italic;
  57.    styleVector[4]:= underline;
  58.    styleVector[5]:= outline;
  59.    styleVector[6]:= shadow;
  60.    styleVector[7]:= condense;
  61.    styleVector[8]:= extend;
  62.    {Other stuff}
  63.    forNowFI.n:= systemFont;
  64.    forNowFI.s:= 12;
  65.    forNowFI.y:= [];
  66.    defaultFI:= forNowFI;
  67.    entr := CHR( 3);
  68.    cRet := CHR(13);
  69.    left := CHR(28);
  70.    right:= CHR(29);
  71.    up   := CHR(30);
  72.    down := CHR(31);
  73.    blnkChr:= ' ';
  74.    blnkPtr:= Ptr(ORD(@blnkChr)+1);  {With Munger}
  75.    WITH screenBits.bounds DO BEGIN
  76.       SetRect(zoomArea,left+origH,top+origV,
  77.          right-origH,bottom-origH);
  78.       SetRect(dragArea,left+4,top+24,
  79.          right-4,bottom-4);
  80.    END;
  81. END;
  82. {••••••••••••••••••••••••••••••••••••••••••••••••}
  83. PROCEDURE SetUpMenus;
  84. BEGIN
  85.    myMenus[1]:= GetMenu(applMID);
  86.    AddResMenu(myMenus[1],'DRVR');
  87.    InsertMenu(myMenus[1],0);
  88.    myMenus[2]:= GetMenu(fileMID);
  89.    InsertMenu(myMenus[2],0);
  90.    myMenus[3]:= GetMenu(editMID);
  91.    InsertMenu(myMenus[3],0);
  92.    myMenus[4]:= GetMenu(fontMID);
  93.    AddResMenu(myMenus[4],'FONT');
  94.    InsertMenu(myMenus[4],0);
  95.    theFontMenu:= myMenus[4];
  96.    myMenus[5]:= GetMenu(stylMID);
  97.    InsertMenu(myMenus[5],0);
  98.    theStylMenu:= myMenus[5];
  99.    SetFontMenu;
  100.    SetSizeMenu;
  101.    SetStylMenu;
  102.    DrawMenuBar;
  103. END;
  104. {••••••••••••••••••••••••••••••••••••••••••••••••}
  105. PROCEDURE CheckMemError;
  106. VAR   e  :  OSErr;
  107. BEGIN
  108.    e:= MemError;
  109.    IF e = noErr THEN Exit(CheckMemError);
  110.    SimpleAlert(Concat('Error #',IntString(e)));
  111.    ExitToShell;
  112. END;
  113. {••••••••••••••••••••••••••••••••••••••••••••••••}
  114. { THE DATA MUST START & END WITH A BLANK. }
  115. PROCEDURE InstallSomeDataInList(v:TVerticalList);
  116. CONST numberOfEntries = 10000;
  117. VAR   h  :  Handle;
  118.       s  :  Str255;
  119.       i,x  :  LongInt;
  120. BEGIN
  121.    h:= NewHandle(1);
  122.    CheckMemError;
  123.    s[0]:= blnkChr;
  124.    BlockMove(@s,h^,1);
  125.    x:= 1;
  126.    FOR i:= 1 TO numberOfEntries DO BEGIN
  127.       CASE i MOD 5 OF
  128.        0:s:= 'What';
  129.        1:s:= 'fools';
  130.        2:s:= 'these';
  131.        3:s:= 'mortals';
  132.        4:s:= 'be!';
  133.       END;
  134.       s:= Concat(IntString(i),'•',s,blnkChr);
  135.       x:= Munger(h,x,NIL,0,Ptr(ORD(@s)+1),
  136.          Length(s));
  137.       CheckMemError;
  138.    END;
  139.    v.InstallData(h);
  140. END;
  141. {••••••••••••••••••••••••••••••••••••••••••••••••}
  142. PROCEDURE SetUpPseudoDialog;
  143. VAR   r  :  Rect;
  144.       f  :  FontIdent;
  145.       theVL  :  TVerticalList;
  146.       thePB  :  TPlainButton;
  147.       theTB  :  TToggleButton;
  148.       the3D  :  TThreeDButton;
  149.       theT3  :  TToggl3DButton;
  150.       theST  :  TStaticText;
  151.       theIC  :  TIcon;
  152.       theAN  :  TAnimation;
  153.    PROCEDURE SetF(nn:INTEGER; ss:Byte; yy:Style);
  154.    BEGIN f.n:= nn; f.s:= ss; f.y:= yy; END;
  155. BEGIN
  156.    New(fakeDlg);
  157.    SetRect(r,105,50,405,300);
  158.    SetF(systemFont,12,[]);
  159.    fakeDlg.IPseudoDialog(r,
  160.       'Big List Demonstration',FALSE,f);
  161.    New(theVL);
  162.    SetRect(r, 10, 10,110,240);
  163.    theVL.IVerticalList(r,fakeDlg.fWindow);
  164.    InstallSomeDataInList(theVL);
  165.    fakeDlg.InstallItem(theVL);
  166.    New(thePB);
  167.    SetRect(r,125, 10,280, 10); {Force computation}
  168.    SetF(geneva,9,[bold,extend]);
  169.    thePB.IPlainButton(r,'About…','1',f);
  170.    fakeDlg.InstallItem(thePB);
  171.    New(theTB);
  172.    SetRect(r,125, 45,280, 45); {Force computation}
  173.    SetF(systemFont,12,[bold]);
  174.    theTB.IToggleButton(r,'Icon','I',f,toggleOff);
  175.    fakeDlg.InstallItem(theTB);
  176.    New(the3D);
  177.    SetRect(r,125, 80,280, 80); {Force computation}
  178.    SetF(systemFont,12,[italic]);
  179.    the3D.IThreeDButton(r,'Window info','W',f);
  180.    fakeDlg.InstallItem(the3D);
  181.    New(theT3);
  182.    SetRect(r,125,115,280,115); {Force computation}
  183.    SetF(monaco,12,[outline]);
  184.    theT3.IToggl3DButton(r,'Animation','A',f,
  185.       toggleOff);
  186.    fakeDlg.InstallItem(theT3);
  187.    New(theST);
  188.    SetRect(r,125,160,280,190);
  189.    SetF(geneva,9,[]);
  190.    theST.IStaticText(r,f,
  191. 'Alas & alack, these words are but static text.');
  192.    fakeDlg.InstallItem(theST);
  193.    New(theIC);
  194.    SetRect(r,140,208,140,208);{Only top,left used}
  195.    theIC.IIcon(r,blApplID);
  196.    fakeDlg.InstallItem(theIC);
  197.    New(theAN);
  198.    SetRect(r,230,190,280,240);{Only top,left used}
  199.    theAN.IAnimation(r,exclamationBaseID,
  200.       exclamationNumber);
  201.    fakeDlg.InstallItem(theAN);
  202.    ShowWindow(fakeDlg.fWindow);
  203. END;
  204. END.
  205.